// 获取频道数据
import {useEffect, useState} from "react";
import {ChannelItem, fetchChannelAPI} from "@/apis/list";


function useTabs() {
    const [channelList, setChannelList] = useState<ChannelItem[]>([]);

    // 渲染完成后执行
    useEffect(() => {
        // 定义函数发送请求
        const getChannelList = async () => {
            try {
                const res = await fetchChannelAPI();
                setChannelList(res.data.data.channels)
            } catch (e) {
                throw new Error("fetch Channel Error")
            }
        }
        // 调用函数
        getChannelList()

    }, [])

    return {
        channelList,

    }

}

export {useTabs}